﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Bots.Index
{
    public class MemoryIncIndexProvider : IncIndexProvider
    {
        private Queue<DomainObject> queue = new Queue<DomainObject>();

        public override void IncIndexAdd(DomainObject domainObject)
        {
            queue.Enqueue(domainObject);
        }

        public override void IncIndexAdd(DomainObject[] domainObjects)
        {
            for (int i = 0; i < domainObjects.Length; i++) {
                queue.Enqueue(domainObjects[i]);
            }
        }

        public override List<DomainObject> FetchIncIndicex(int maxCount)
        {
            List<DomainObject> domainObjects = new List<DomainObject>();
            if (maxCount > queue.Count)
            {
                maxCount = queue.Count;
            }
            while (maxCount != 0) {
                domainObjects.Add(queue.Dequeue());
                maxCount--;
            }
            return domainObjects;
        }

    }
}
